import matplotlib
import matplotlib.pyplot as plt
import numpy as np

topics = [
    ['tool', 'system', 'performance', 'API', 'tools', 'machine', 'userspace', 'bridge', 'emulator', 'qemu', 'openeuler'],
    ['detect', 'container', 'system', 'operating', 'scripts', 'kernel', 'patch', 'Problem'],
    ['repository', 'content', 'source', 'website', 'documents', 'Environment'],
    ['framework', 'Kiran', 'performance', 'generation', 'memory', 'desktop', 'supports', 'expansion'],
    ['SIG', 'repository', 'repo', 'chip', 'CloudNative', 'Issue', 'entry', 'operation'],
    ['modules', 'service', 'rpm', 'tool', 'tools', 'bot', 'leak', 'JDK', 'plugin', 'OpenStack', 'software', 'DPU', 'packager'],
    ['repository', 'OpenDesign', 'OS', 'computing', 'framework']
]

topics_num = [0,0,0,0,0,0,0]

file = open("OpenEuler_description.csv", encoding="utf-8", errors='ignore').read().split("\n")
for i in range(len(file)):
    seg_list = file[i].split()
    for w in seg_list:
        for j in range(len(topics)):
            if w in topics[j]:
                topics_num[j] += 1

y = np.array(topics_num)
plt.pie(y,
        labels=['topic1','topic2','topic3','topic4','topic5','topic6','topic7']
        )
plt.show()